{% load i18n static admin_list tree_filter_change_list adminlte_list %}

<!--将filter和search合并到一个form中进行处理-->

<form id="changelist-search" class="form-inline" method="get">
    {% block filters %}
        {% if cl.has_filters %}
            {% for spec in cl.filter_specs %}{% is_tree_filter spec as is_tree %}{% if not is_tree %}
                {% admin_list_tree_filter cl spec %}{% endif %}{% endfor %}
        {% endif %}
    {% endblock %}

    {% if cl.search_fields %}
        <!-- DIV needed for valid HTML -->
        <div class="form-group">
            <input class="form-control" type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}"
                   id="searchbar" autofocus>
        </div>
    {% endif %}
    {% if cl.has_filters or cl.search_fields %}
        <div class="form-group" id="search_group">
            <button type="submit" class="btn btn-primary" style="margin-right: 5px;">{% trans 'Search' %}</button>
            {% if show_result_count %}
                <span class="small quiet">{% blocktrans count counter=cl.result_count %}{{ counter }} result
                    {% plural %}{{ counter }} results{% endblocktrans %} (<a
                        href="?{% if cl.is_popup %}_popup=1{% endif %}">{% if cl.show_full_result_count %}
                    {% blocktrans with full_result_count=cl.full_result_count %}{{ full_result_count }} total
                    {% endblocktrans %}{% else %}{% trans "Show all" %}{% endif %}</a>)</span>
            {% endif %}
            {% admin_extra_filters cl as extra_filters %}
            {% for pair in extra_filters.items %}
                {% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}">{% endif %}
            {% endfor %}
        </div>
    {% endif %}
</form>
